package equipmentManager.bean;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 一类设备
 */
public class Equipment {
    private String name;
    private String type;
    //时间戳
    private long time;

    //设备状态
    private int useableNum;//可用 1
    private int lendNum;//借出 2
    private int breakNum;//损坏 3

    public Equipment() {
        this.time = System.currentTimeMillis();
    }

    public Equipment(String name, String type, long time, int useableNum, int lendNum, int breakNum) {
        this.name = name;
        this.type = type;
        this.time = time;
        this.useableNum = useableNum;
        this.lendNum = lendNum;
        this.breakNum = breakNum;
    }

    /**
     * 根据状态设置数量
     * @param num 数量
     * @param state 状态
     */
    public void setNumByState(int num,String state){
        switch (state){
            case "1":
                useableNum = num;
                break;
            case "2":
                lendNum = num;
                break;
            case "3":
                breakNum = num;
                break;
        }
    }

    public String getTime() {
        Date date = new Date(time);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }


    public int getUseableNum() {
        return useableNum;
    }

    public void setUseableNum(int useableNum) {
        this.useableNum = useableNum;
    }

    public int getLendNum() {
        return lendNum;
    }

    public void setLendNum(int lendNum) {
        this.lendNum = lendNum;
    }

    public int getBreakNum() {
        return breakNum;
    }

    public void setBreakNum(int breakNum) {
        this.breakNum = breakNum;
    }

    @Override
    public String toString() {
        return "Equipment{" +
                "name='" + name + '\'' +
                ", type='" + type + '\'' +
                ", time=" + time +
                ", useableNum=" + useableNum +
                ", lendNum=" + lendNum +
                ", breakNum=" + breakNum +
                '}';
    }
}
